package com.nulldev.util.java.extendedUI.cSwing;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Graphics2D;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import com.nulldev.util.java.swing.SwingUtil;
import com.nulldev.util.java.swing.canvas.PaintMethod;
import com.nulldev.util.java.swing.canvas.SmoothCanvas;
import com.nulldev.util.java.swing.font.FontManager;
import com.nulldev.util.java.utils.color.ColorUtil;
import com.nulldev.util.other.FPSCounter;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.LayoutStyle.ComponentPlacement;

public class cSwingAbout extends cSwing {

	private JPanel contentPane;

	/**
	 * Launch the application.
	 */
	public static void main() {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					cSwingAbout frame = new cSwingAbout();
					SwingUtil.centerFrame(frame);
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public cSwingAbout() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		setTitle("cSwing: About");
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		
		JPanel panel = new JPanel();
		contentPane.add(panel, BorderLayout.CENTER);
		
		JLabel lblCswingUiFramework = new JLabel("cSwing UI Framework");
		
		JLabel lblPartOfNullutil = new JLabel("Part of nullUtil 2.7");
		
		JLabel lblUsesTheIcomoon = new JLabel("Uses the IcoMoon font to provide base icons");
		final FPSCounter fpsc = new FPSCounter();
		fpsc.start();
		final SmoothCanvas panel_1 = new SmoothCanvas() {
			
			@Override
			public void drawCanvas(Graphics2D g2d) {
				g2d.setFont(FontManager.getFontSet());
				fpsc.timeStart();
				g2d.setColor(ColorUtil.rainbow(20, 1.0f));
				g2d.fillRect(0, 0, getWidth(), getHeight());
				g2d.setColor(Color.BLACK);
				g2d.drawString("SmoothCanvas Renderer", 5, 15);
				g2d.drawString("FPS: " + fpsc.getFPS(), 5, 30);
				g2d.drawString("FPS LOCK: 60 (+- 5FPS)", 5, 45);
				g2d.drawString("Renderer: " + SwingUtil.getRenderer(), 5, 60);
				fpsc.callFPS();
				fpsc.timeEnd();
			}
		};
		panel_1.usePaintMethod(PaintMethod.REPAINT);
		panel_1.setAAEnabled(true);
		panel_1.setFPS(64);
		
		JLabel lblAFullRewrite = new JLabel("A full rewrite of the original eSwing framework.");
		GroupLayout gl_panel = new GroupLayout(panel);
		gl_panel.setHorizontalGroup(
			gl_panel.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_panel.createSequentialGroup()
					.addContainerGap()
					.addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
						.addComponent(panel_1, GroupLayout.DEFAULT_SIZE, 416, Short.MAX_VALUE)
						.addComponent(lblPartOfNullutil)
						.addComponent(lblCswingUiFramework)
						.addComponent(lblUsesTheIcomoon)
						.addComponent(lblAFullRewrite))
					.addContainerGap())
		);
		gl_panel.setVerticalGroup(
			gl_panel.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_panel.createSequentialGroup()
					.addContainerGap()
					.addComponent(lblCswingUiFramework)
					.addPreferredGap(ComponentPlacement.UNRELATED)
					.addComponent(lblAFullRewrite)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(panel_1, GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE)
					.addGap(18)
					.addComponent(lblUsesTheIcomoon)
					.addGap(18)
					.addComponent(lblPartOfNullutil)
					.addContainerGap())
		);
		panel.setLayout(gl_panel);
	}
}
